import pandas as pd
import csv
 
 
data = pd.read_csv("/home/zshengbo/py/ChampSim-master/Temporary.csv")
 
data_new=data.drop(["Unnamed: 0"],axis=1) 
#for num in range(1,178898):
#  data=data_new
#  data_new=data.drop([(208902-num)])
data_new.to_csv("/home/zshengbo/py/ChampSim-master2/lin1.csv",index=0)

data = pd.read_csv("/home/zshengbo/py/ChampSim-master2/lin1.csv")
print(data)
#print(0)

data_new=data
#for num in range(0,30005):  
#  data["PC"][num]=str(data["PC"][num])
data_new["label"]=data["Deltas"]
data_new["text"]=data["PC"]
data_new=data_new.drop(["PC"],axis=1) 
#data_new=data_new.drop(["Deltas"],axis=1) 
print(data_new)
data_new.to_csv("/home/zshengbo/py/ChampSim-master2/lin1.csv",index=0)

import random
data = pd.read_csv("/home/zshengbo/py/ChampSim-master2/lin1.csv")
data_new=data
mylist=dict()
k=0
data_new["Deltas"]=data_new["label"]
for num in range(5,len(data)):
  #data_new["label"][num-5]=mylist.setdefault(data_new["label"][num-5], default=len(mylist.keys())+1)
  if str(data_new["label"][num-5]) in mylist:
    data_new["label"][num-5]=mylist[str(data_new["label"][num-5])]
  else:
    mylist[str(data_new["label"][num-5])]=k
    #print(data_new["label"][num-5])
    data_new["label"][num-5]=k
    k=k+1
    
#print(mylist.keys())
#print(mylist.values())  
for num in range(0,len(data)-5):  
  data_new["text"][num]=(str(data["text"][num])+" "+str(data["text"][num+1])+" "+str(data["text"][num+2])+" "+str(data["text"][num+3])+" "+str(data["text"][num+4]))
  #data_new["Deltas"][num]=(str(data["Deltas"][num])+" "+str(data["Deltas"][num+1])+" "+str(data["Deltas"][num+2])+" "+str(data["Deltas"][num+3]))
  #data_new["text"][num] = data_new["text"][num] + ' ' + data_new["Deltas"][num]
  #data_new["text"][num]=(str(data["Deltas"][num])+" "+str(data["Deltas"][num+1])+" "+str(data["Deltas"][num+2])+" "+str(data["Deltas"][num+3]))      
    
data_new=data_new.drop([len(data)-5])
data_new=data_new.drop([len(data)-4])  
data_new=data_new.drop([len(data)-3])  
data_new=data_new.drop([len(data)-2])  
data_new=data_new.drop([len(data)-1])      

#data_new=data_new.drop(["text"],axis=1)

data_new=data_new.drop(["Deltas"],axis=1)  

#data_new=data_new.drop(["Deltas"],axis=1)  
print(data_new)

data_new.to_csv("/home/zshengbo/py/ChampSim-master2/lin.csv",index=0)

#data = pd.read_csv("/home/zshengbo/py/ChampSim-master2/lin.csv")
#data_new=data
#for num in range(1,1000):
#  data=data_new
#  data_new=data.drop([(1000-num)])

#data_new.to_csv("/home/zshengbo/py/ChampSim-master2/lin.csv",index=0)
